<template>
	<view>
		<view class="page">
			<view v-if="data_list_loding_msg != ''" class="goods-item br-b-dashed oh padding-main">
				<view class="stopbianji tc">
					<view>{{data_list_loding_msg}}</view>
				</view>
			</view>
			<view v-if="(hotel_info || null) != null" class="goods-item br-b-dashed oh padding-main">
				<view v-if="hotel_info.id > 0" class="stopbianji">
					<view v-if="hotel_info.status == 0">已提交审核，请耐心等待！审核前您还可以再编辑一次资料！（当前可编辑：{{edit_num}}次）</view>
					<view v-if="hotel_info.status == 1">入驻失败，请重新编辑提交！失败原因：{{hotel_info.admin_note}}</view>
					<view v-if="hotel_info.status == 2">入驻成功！当前页面仅供查看！</view>
				</view>
				<form @submit="form_submit" class="form-container">
					<view class="goods-spec-choose plugins-yxform bg-white padding-main border-radius-main">
						<view class="item">
							<view class="title">{{$t('fengcheche.classinfo.reg.comcat')}}<text class="form-group-tips-must">*</text></view>
							<view class="spec">
								<block v-if="com_status < 2">
									<view class="yxsection">
									    <picker name="category_id_key" @change="yxselect" :value="hotel_info.category_id_key" :range="shopcategory" range-key="name" >
											<view :class="'name ' + ((shopcategory.length == 0) ? 'cr-grey' : 'cr-base' )">{{(shopcategory.length == 0) ? $t('fengcheche.classinfo.reg.comcattips') : (((shopcategory[hotel_info.category_id_key] || null) == null) ? hotel_info.category_id_default_value : shopcategory[hotel_info.category_id_key]['name'])}}</view>
									    </picker>
									</view>
								</block>
								<block v-else>
									<view class="margin-vertical-main">{{hotel_info.category_id_default_value}}</view>
								</block>
							</view>
						</view>
						<view class="item">
							<view class="title">{{$t('fengcheche.classinfo.reg.regtype')}}<text class="form-group-tips-must">*</text></view>
							<view class="spec">
								<block v-if="com_status < 2">
									<view class="uni-list">
										<radio-group @change="yxonclick">
											<label class="yxradio">
												<radio value="0" :checked="hotel_info.type == 0" color="#36abff" style="transform:scale(0.7);" name="type" />{{$t('fengcheche.classinfo.reg.type0')}}
											</label>
											<label class="yxradio">
												<radio value="1" :checked="hotel_info.type == 1" color="#36abff" style="transform:scale(0.7);" name="type" />{{$t('fengcheche.classinfo.reg.type1')}}
											</label>
										</radio-group>
									</view>
								</block> 
								<block v-else>
									<view class="margin-vertical-main" v-if="hotel_info.type == 0">{{$t('fengcheche.classinfo.reg.type0')}}</view>
									<view class="margin-vertical-main" v-else>{{$t('fengcheche.classinfo.reg.type1')}}</view>
								</block>
							</view>
						</view>
						<view class="item">
							<view class="title" v-if="hotel_info.type == 0">{{$t('fengcheche.classinfo.reg.type0name')}}<text class="form-group-tips-must">*</text></view>
							<view class="title" v-else>{{$t('fengcheche.classinfo.reg.type1name')}}<text class="form-group-tips-must">*</text></view>
							<view class="spec">
								<block v-if="com_status < 2">
									<input type="text" name="name" class="form-item margin-vertical-main wh-auto yxform-item" maxlength="200" placeholder-class="cr-ccc" :placeholder="((hotel_info.type == 0) ? $t('fengcheche.classinfo.reg.type0name') : $t('fengcheche.classinfo.reg.type1name'))" @blur="yxblur" @confirm="yxblur" data-value="name" :value="hotel_info.name" />
								</block>
								<block v-else>
									<view class="margin-vertical-main">{{hotel_info.name}}</view>
								</block>
							</view>
						</view>
						<view class="item">
							<view class="title" v-if="hotel_info.type == 0">{{$t('fengcheche.classinfo.reg.jieshao0')}}<text class="form-group-tips-must">*</text></view>
							<view class="title" v-else>{{$t('fengcheche.classinfo.reg.jieshao1')}}<text class="form-group-tips-must">*</text></view>
							<view class="spec">
								<block v-if="com_status < 2">
									<textarea :placeholder="(hotel_info.type == 0) ? $t('fengcheche.classinfo.reg.jieshaotips0') : $t('fengcheche.classinfo.reg.jieshaotips1')" name="com_describe" class="form-item margin-vertical-main wh-auto yxform-item" auto-height="true" :value="hotel_info.com_describe" data-value="com_describe" @blur="yxblur" @confirm="yxblur" maxlength="10000"></textarea>
								</block>
								<block v-else>
									<view class="margin-vertical-main">{{hotel_info.com_describe}}</view>
								</block>
							</view>
						</view>
						<view class="item">
							<view class="title">{{$t('fengcheche.serv.laoban.field11')}}<text class="form-group-tips-must">*</text></view>
							<view class="spec">
								<block v-if="com_status < 2">
									<input type="text" name="contact_tel" maxlength="30" placeholder-class="cr-ccc" class="form-item margin-vertical-main wh-auto yxform-item" :placeholder="$t('fengcheche.serv.laoban.field11')" @blur="yxblur" @confirm="yxblur" data-value="contact_tel" :value="hotel_info.contact_tel" />
								</block>
								<block v-else>
									<view class="margin-vertical-main">{{hotel_info.contact_tel}}</view>
								</block>
							</view>
						</view>
						<view class="item">
							<view class="title">{{$t('fengcheche.classinfo.reg.comwx')}}<text class="form-group-tips-must">*</text></view>
							<view class="spec">
								<block v-if="com_status < 2">
									<input type="text" name="contact_wx" maxlength="30" placeholder-class="cr-ccc" class="form-item margin-vertical-main wh-auto yxform-item" :placeholder="$t('fengcheche.classinfo.reg.comwx')" @blur="yxblur" @confirm="yxblur" data-value="contact_wx" :value="hotel_info.contact_wx" />
								</block>
								<block v-else>
									<view class="margin-vertical-main">{{hotel_info.contact_wx}}</view>
								</block>
							</view>
						</view>
						<view class="item">
							<view class="title" v-if="hotel_info.type == 0">{{$t('fengcheche.classinfo.reg.logo0')}}<text class="form-group-tips-must">*</text></view>
							<view class="title" v-else>{{$t('fengcheche.classinfo.reg.logo1')}}<text class="form-group-tips-must">*</text></view>
							<view class="spec">
								<view class="form-container-upload oh">
									<view class="form-upload-data margin-vertical-main">
										<view v-if="com_status == 2" class="fl">
											<image :src="(hotel_info.logo || null) != null ? hotel_info.logo : common_static_url+'default-images.jpg'" data-value="logo" mode="aspectFill"></image>
										</view>
										<view v-else class="fl pr">
											<text v-if="(hotel_info.logo || null) != null" class="delete-icon" @tap="upload_delete_event" data-value="logo">x</text>
											<image :src="(hotel_info.logo || null) != null ? hotel_info.logo : common_static_url+'default-images.jpg'" data-value="logo" mode="aspectFill" @tap="file_upload_event"></image>
										</view>
									</view>
								</view>
							</view>
						</view>
						<view class="item" v-if="hotel_info.type == 0">
							<view class="title">营业执照<text class="form-group-tips-must">*</text><text class="form-group-tips">请使用营业执照原件拍摄，图片要清晰</text></view>
							<view class="spec">
								<view class="form-container-upload oh">
									<view class="form-upload-data margin-vertical-main">
										<view v-if="com_status == 2" class="fl">
											<image :src="(hotel_info.com_images || null) != null ? hotel_info.com_images : common_static_url+'company.jpg'" data-value="com_images" mode="aspectFill"></image>
										</view>
										<view v-else class="fl pr">
											<text v-if="(hotel_info.com_images || null) != null" class="delete-icon" @tap="upload_delete_event" data-value="com_images">x</text>
											<image :src="(hotel_info.com_images || null) != null ? hotel_info.com_images : common_static_url+'company.jpg'" data-value="com_images" mode="aspectFill" @tap="file_upload_event"></image>
										</view>
									</view>
								</view>
							</view>
						</view>
						<view class="item" v-if="hotel_info.type == 0">
							<view class="title">统一社会信用代码<text class="form-group-tips-must">*</text></view>
							<view class="spec">
								<block v-if="com_status < 2">
									<input type="text" name="contact_name" class="form-item margin-vertical-main wh-auto yxform-item" maxlength="20" placeholder-class="cr-ccc" placeholder="填写统一社会信用代码" @blur="yxblur" @confirm="yxblur" data-value="contact_name" :value="hotel_info.contact_name" />
								</block>
								<block v-else>
									<view class="margin-vertical-main">{{hotel_info.contact_name}}</view>
								</block>
							</view>
						</view>
						<view class="item" v-if="hotel_info.type == 0">
							<view class="title">法人<text class="form-group-tips-must">*</text></view>
							<view class="spec">
								<block v-if="com_status < 2">
									<input type="text" name="faren" class="form-item margin-vertical-main wh-auto yxform-item" maxlength="20" placeholder-class="cr-ccc" placeholder="填写法人姓名" @blur="yxblur" @confirm="yxblur" data-value="faren" :value="hotel_info.faren" />
								</block>
								<block v-else>
									<view class="margin-vertical-main">{{hotel_info.faren}}</view>
								</block>
							</view>
						</view>
						<view class="item" v-if="hotel_info.type == 0">
							<view class="title">公司照片<text class="form-group-tips-must"></text><text class="form-group-tips">请拍摄实景，图片要清晰</text></view>
							<view class="spec">
								<view class="form-container-upload oh">
									<view class="form-upload-data margin-vertical-main">
										<view v-if="com_status == 2" class="fl">
											<image :src="(hotel_info.jing_images || null) != null ? hotel_info.jing_images : common_static_url+'default-images.jpg'" data-value="jing_images" mode="aspectFill"></image>
										</view>
										<view v-else class="fl pr">
											<text v-if="(hotel_info.jing_images || null) != null" class="delete-icon" @tap="upload_delete_event" data-value="jing_images">x</text>
											<image :src="(hotel_info.jing_images || null) != null ? hotel_info.jing_images : common_static_url+'default-images.jpg'" data-value="jing_images" mode="aspectFill" @tap="file_upload_event"></image>
										</view>
									</view>
								</view>
							</view>
						</view>
						<view class="item" v-if="hotel_info.type == 1">
							<view class="title">身份证号码<text class="form-group-tips-must"></text></view>
							<view class="spec">
								<block v-if="com_status < 2">
									<input type="idcard" name="idcard_number" :value="hotel_info.idcard_number || ''" maxlength="18" placeholder-class="cr-ccc" class="form-item margin-vertical-main wh-auto yxform-item" placeholder="身份证号码格式最多18个字符" @blur="yxblur" @confirm="yxblur" data-value="idcard_number"  />
								</block>
								<block v-else>
									<view class="margin-vertical-main">{{hotel_info.idcard_number}}</view>
								</block>
							</view>
						</view>
						<view class="item" v-if="hotel_info.type == 1">
							<view class="title">身份证照片<text class="form-group-tips-must"></text></view>
							<view class="spec">
								<view class="form-container-upload oh idcard-container">
									<view class="form-upload-data margin-vertical-main">
										<view class="item2 fl pr">
											<block v-if="com_status == 2">
												<image :src="(hotel_info.idcard_front || null) != null ? hotel_info.idcard_front : common_static_url+'idcard-front.jpg'" data-value="idcard_front" mode="aspectFill"></image>
											</block>
											<block v-else>
												<text v-if="(hotel_info.idcard_front || null) != null" class="delete-icon" @tap="upload_delete_event" data-value="idcard_front">x</text>
												<image :src="(hotel_info.idcard_front || null) != null ? hotel_info.idcard_front : common_static_url+'idcard-front.jpg'" data-value="idcard_front" mode="aspectFill" @tap="file_upload_event"></image>
											</block>
										</view>
										<view class="item2 fl pr">
											<block v-if="com_status == 2">
												<image :src="(hotel_info.idcard_back || null) != null ? hotel_info.idcard_back : common_static_url+'idcard-back.jpg'" data-value="idcard_back" mode="aspectFill"></image>
											</block>
											<block v-else>
												<text v-if="(hotel_info.idcard_back || null) != null" class="delete-icon" @tap="upload_delete_event" data-value="idcard_back">x</text>
												<image :src="(hotel_info.idcard_back || null) != null ? hotel_info.idcard_back : common_static_url+'idcard-back.jpg'" data-value="idcard_back" mode="aspectFill" @tap="file_upload_event"></image>
											</block>
										</view>
									</view>
								</view>
							</view>
						</view>
						
						<view class="item" style="padding-bottom: 0;">
							<view class="title">所在地<text class="form-group-tips-must">*</text></view>
							<view class="spec">
								<block v-if="is_user_address_forbid_choice_region == 0 && com_status < 2">
									<view class="select-address oh margin-vertical-main">
										<view class="section fl">
											<picker name="province" @change="select_province_event" :value="province_value" :range="province_list" range-key="name">
												<view :class="'name ' + ((province_value == null) ? 'cr-grey' : 'cr-base' )">{{((province_list[province_value] || null) == null) ? default_province : province_list[province_value]['name']}}</view>
											</picker>
										</view>
										<view class="section fl">
											<picker v-if="(province_id || null) != null" name="city" @change="select_city_event" :value="city_value" :range="city_list" range-key="name">
												<view :class="'name ' + ((city_value == null) ? 'cr-grey' : 'cr-base' )">{{((city_list[city_value] || null) == null) ? default_city : city_list[city_value]['name']}}</view>
											</picker>
											<text v-else class="cr-grey" @tap="region_select_error_event" :data-value="$t('extraction-apply.extraction-apply.liqbru')">{{$t('extraction-apply.extraction-apply.liqbru')}}</text>
										</view>
										<view class="section fl">
											<picker v-if="(city_id || null) != null" name="county" @change="select_county_event" :value="county_value" :range="county_list" range-key="name">
												<view :class="'name ' + ((county_value == null) ? 'cr-grey' : 'cr-base' )">{{((county_list[county_value] || null) == null) ? default_county : county_list[county_value]['name']}}</view>
											</picker>
											<text v-else class="cr-grey" @tap="region_select_error_event" :data-value="$t('extraction-apply.extraction-apply.r4q86m')">{{$t('extraction-apply.extraction-apply.r4q86m')}}</text>
										</view>
									</view>
								</block>
								<block v-else>
									<view v-if="(hotel_info.province_name || null) != null" class="margin-vertical-main" >{{hotel_info.province_name}}{{hotel_info.city_name || ''}}{{hotel_info.county_name || ''}}</view>
								</block>
							</view>
						</view>
						<view class="item">
							<view class="title">详细地址<block v-if="hotel_info.type == 0"><text v-if="com_status < 2" class="form-group-tips-must">*</text></block><text v-if="home_user_address_map_status == 1 && com_status < 2" class="fr form-group-tips">地理位置</text></view>
							<view class="spec pr" style="height:60rpx;">
								<input type="text" name="address" :value="hotel_info.address || ''" maxlength="80" placeholder-class="cr-grey" :class="'margin-vertical-main cr-base bs-bb '+(home_user_address_map_status == 1 ? 'address-value' : '')" placeholder="详细地址1~80个字符" style="margin-top:30rpx;" @blur="yxblur" @confirm="yxblur" data-value="address">
								<view v-if="home_user_address_map_status == 1 && com_status < 2" @tap="choose_location_event" class="map-icon pa cp tc">
									<uni-icons type="location" size="20" color="#666"></uni-icons>
								</view>
							</view>
							<view class="cr-red">{{dingwei_address}}</view>
						</view>
						<view class="item">
							<view class="title">补充图片1<text class="form-group-tips-must"></text></view>
							<view class="spec">
								<view class="form-container-upload oh">
									<view class="form-upload-data margin-vertical-main">
										<view v-if="com_status == 2" class="fl">
											<image :src="(hotel_info.com_pic1 || null) != null ? hotel_info.com_pic1 : common_static_url+'default-images.jpg'" data-value="com_pic1" mode="aspectFill"></image>
										</view>
										<view v-else class="fl pr">
											<text v-if="(hotel_info.com_pic1 || null) != null" class="delete-icon" @tap="upload_delete_event" data-value="com_pic1">x</text>
											<image :src="(hotel_info.com_pic1 || null) != null ? hotel_info.com_pic1 : common_static_url+'default-images.jpg'" data-value="com_pic1" mode="aspectFill" @tap="file_upload_event"></image>
										</view>
									</view>
								</view>
							</view>
						</view>
						<view class="item">
							<view class="title">补充图片2<text class="form-group-tips-must"></text></view>
							<view class="spec">
								<view class="form-container-upload oh">
									<view class="form-upload-data margin-vertical-main">
										<view v-if="com_status == 2" class="fl">
											<image :src="(hotel_info.com_pic2 || null) != null ? hotel_info.com_pic2 : common_static_url+'default-images.jpg'" data-value="com_pic2" mode="aspectFill"></image>
										</view>
										<view v-else class="fl pr">
											<text v-if="(hotel_info.com_pic2 || null) != null" class="delete-icon" @tap="upload_delete_event" data-value="com_pic2">x</text>
											<image :src="(hotel_info.com_pic2 || null) != null ? hotel_info.com_pic2 : common_static_url+'default-images.jpg'" data-value="com_pic2" mode="aspectFill" @tap="file_upload_event"></image>
										</view>
									</view>
								</view>
							</view>
						</view>
						<view class="item">
							<view class="title">补充图片3<text class="form-group-tips-must"></text></view>
							<view class="spec">
								<view class="form-container-upload oh">
									<view class="form-upload-data margin-vertical-main">
										<view v-if="com_status == 2" class="fl">
											<image :src="(hotel_info.com_pic3 || null) != null ? hotel_info.com_pic3 : common_static_url+'default-images.jpg'" data-value="com_pic3" mode="aspectFill"></image>
										</view>
										<view v-else class="fl pr">
											<text v-if="(hotel_info.com_pic3 || null) != null" class="delete-icon" @tap="upload_delete_event" data-value="com_pic3">x</text>
											<image :src="(hotel_info.com_pic3 || null) != null ? hotel_info.com_pic3 : common_static_url+'default-images.jpg'" data-value="com_pic3" mode="aspectFill" @tap="file_upload_event"></image>
										</view>
									</view>
								</view>
							</view>
						</view>
						
						<!-- 协议 -->
						<view class="margin-top-xxxl cr-gray" v-if="com_status < 2">
						    <view class="dis-inline-block va-m" @tap="agreement_change">
						        <radio-group class="dis-inline-block va-m" style="transform:scale(0.6)">
						            <label>
						                <radio value="agreement" color="#36abff" :checked="agreement_status" />
						            </label>
						        </radio-group>
						    </view>
						    <view class="dis-inline-block va-m">
						        <text v-if="com_status < 2">{{$t('login.login.nddg2x')}} </text><text class="cr-main" @tap="popup_xieyi_event">{{$t('fengcheche.classinfo.reg.xieyi')}}</text>
						    </view>
						</view>
										
						<view class="padding-main" v-if="com_status < 2">
							<button class="cr-white round text-size" style="background-color: #36abff;" type="default" form-type="submit" hover-class="none" :disabled="form_submit_disabled_status">{{$t('common.submit')}}</button>
						</view>
					</view>
				</form>
				<component-popup :propShow="popup_xieyi_status" propPosition="bottom" @onclose="popup_xieyi_close_event">
				    <view class="padding-horizontal-main padding-top-main bg-white bottom-line-exclude">
				        <view class="close oh">
				            <view class="fr" @tap.stop="popup_xieyi_close_event">
				                <icon type="clear" size="20"></icon>
				            </view>
				        </view>
				        <view class="plugins-xieyi-container padding-bottom-main">
				            <view v-if="xieyi.length > 0">
				            	<view class="goods-parameters bg-white">
				            		<view class="content-item">
										<view class="bigtit">{{$t('fengcheche.serv.laoban.xieyiname')}}</view>
				            			<block v-for="(item, index) in xieyi" :key="index">
				            				<view class="item">
				            					<text class="value">{{item}}</text>
				            				</view>
				            			</block>
				            		</view>
				            	</view>
				            </view>
				        </view>
						<button v-if="com_status < 2" class="goods-popup-submit cr-white bg-main" type="default" @tap="xieyi_enter_confirm_event" hover-class="none">{{$t('fengcheche.serv.laoban.agreexieyi')}}</button>
				    </view>
				</component-popup>
			</view>
			<!-- #ifdef APP-PLUS -->
			<yk-authpup ref="authpup" type="top" @changeAuth="changeAuth" :permissionID="permissionID"></yk-authpup>
			<!-- #endif -->
			<component-classinfo-footer :propBaseData="data_base"></component-classinfo-footer>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	// #ifdef APP-PLUS
	import ykAuthpup from "@/components/yk-authpup/yk-authpup";
	// #endif
	import componentQuickNav from "@/components/quick-nav/quick-nav";
	import componentCopyright from "@/components/copyright/copyright";
	import componentOnlineService from "@/components/online-service/online-service";
	import componentClassinfoFooter from '../public/footer';
	import {classinfo_base_info} from '@/pages/fcc/classinfo/public/common.js';
	import componentPopup from "@/components/popup/popup";
	var common_static_url = app.globalData.get_static_url('classinfo', true);
	export default {
		data() {
			return {
				params: null,
				common_static_url: common_static_url,
				data_list_loding_status: 1,
				data_list_loding_msg: '',
				editor_path_type: 'classinfo-company',//默认一个，防止为空
				province_list: [],
				city_list: [],
				county_list: [],
				province_id: null,
				city_id: null,
				county_id: null,
				
				default_province: this.$t('extraction-apply.extraction-apply.s3h5o3'),
				default_city: this.$t('extraction-apply.extraction-apply.4s4s15'),
				default_county: this.$t('extraction-apply.extraction-apply.fk4gw5'),
				
				province_value: null,
				city_value: null,
				county_value: null,
				
				user_location_cache_key: app.globalData.data.cache_userlocation_key,
				user_location: null,
				
				address_discern_value: '',
				form_submit_disabled_status: false,
				
				// 基础配置
				home_user_address_map_status: 1,
				home_user_address_idcard_status : 1,
				is_user_address_location_discern: 1,
				is_user_address_forbid_choice_region: 0,
				
				edit_num:0,//可编辑次数
				img_data:[],
				agreement_status: false,
				tempid01:null,
				com_id:0,
				com_status:0,
				data_base:null,
				hotel_info:null,
				shopcategory: [],
				xieyi:[],
				popup_xieyi_status:false,
				dingwei_address: '',
				permissionID: '',
				// 自定义分享信息
				share_info: {},
			}
		},
		components: {
			// #ifdef APP-PLUS
			ykAuthpup,
			// #endif
		    componentQuickNav,
		    componentCopyright,
		    componentOnlineService,
			componentClassinfoFooter,
			componentPopup
		},
		onReady() {
			// 清除位置缓存信息
			this.user_location_remove();
		},
		onLoad(params) {
		    this.setData({
		        params: params
		    });
			// 初始化
			this.init();
		},
		onShow() {
			app.globalData.page_event_onshow_handle();
			
			this.user_location_init();
		},
		
		// 下拉刷新
		onPullDownRefresh(e) {
		    this.init();
		},

		methods: {
			// 加载之前
			init() {
				// 先获取语言基础信息
				classinfo_base_info()
				.then(data=>{
					this.init_before(data)
					.then(()=>{
						this.init_real();
					});
				});
			},
			// 设置本页参数
			init_before(data){
				var self = this;
				return new Promise((resolve, reject) => {
					self.setData({
						data_base: data
					});
					resolve();
				});
			},
			init_real() {
				var self = this;
				var user = app.globalData.get_user_info(this, "init_real");
				if (user != false) {
					self.init_local_hotel_info()
					.then(() => {
						self.get_province_list()
						.then(()=>{
							self.get_data();
							
							// 分享菜单处理
							app.globalData.page_share_handle(this.share_info);
						}).catch(err =>{
							console.log(`error：${err}`)
						});
					});
				} else {
					uni.stopPullDownRefresh();
			
					// 分享菜单处理
					app.globalData.page_share_handle();
				}
			},
			
			// 有缓存则初始化缓存数据
			init_local_hotel_info(){
				var self = this;
				return new Promise(function(resolve, reject) {
					uni.getStorage({
						key: 'classinfo_user_renzheng_info',
						success: function (res) {
							if((res.data || null) != null)
							{
								self.setData({
									hotel_info:res.data,
									agreement_status:res.data.agreement_status || false,
								});
							}
						},
						complete: function(res){
							// 无论成功与否，都正确返回
							resolve();
						}
					});
				});
			},
			
			yxblur(e){
				var name = e.currentTarget.dataset.value;
				var value = e.detail.value;
				var temp = this.hotel_info;
				temp[name] = value;
				this.setData({
				   hotel_info:temp
				});
				uni.setStorageSync('classinfo_user_renzheng_info', temp);
			},
			
			// 下拉
			yxselect(e){
				var index = parseInt(e.detail.value) || 0;// 选中结果数组序号
				if (index >= 0) {
					var temp = this.hotel_info;
					temp['category_id_key'] = index;
					temp['category_id'] = (this.shopcategory.length > 0) ? this.shopcategory[index]['id'] : null;
					this.setData({
					   hotel_info:temp
					});
					uni.setStorageSync('classinfo_user_renzheng_info', temp);
				}
			},
			
			// 单选多选
			yxonclick(e){
				var value = e.detail.value;
				var temp = this.hotel_info;
				temp['type'] = parseInt(value);
				this.setData({
				   hotel_info:temp
				});
				uni.setStorageSync('classinfo_user_renzheng_info', temp);
			},
			
			// 协议开启弹层
			popup_xieyi_event(e) {
			    if(!app.globalData.is_single_page_check()) {
			        return false;
			    }
			    this.setData({
			        popup_xieyi_status: true
			    });
			},
			
			// 协议弹层关闭
			popup_xieyi_close_event(e) {
			    this.setData({
			        popup_xieyi_status: false
			    });
			},
			
			// 协议改变
			agreement_change(e) {
				var temp = this.hotel_info;
				temp['agreement_status'] = !this.agreement_status;
				this.setData({
				   hotel_info:temp,
				   agreement_status:temp['agreement_status']
				});
				uni.setStorageSync('classinfo_user_renzheng_info', temp);
			},
			
			// 同意该协议
			xieyi_enter_confirm_event(){
				var temp = this.hotel_info;
				temp['agreement_status'] = true;
				this.setData({
					hotel_info:temp,
				    agreement_status: true,
					popup_xieyi_status: false
				});
				uni.setStorageSync('classinfo_user_renzheng_info', temp);
			},
			
			// 获取数据
			get_data() {
			    uni.request({
			        url: app.globalData.get_request_url("detail", "company", "classinfo"),
			        method: "POST",
			        data: this.params,
			        dataType: "json",
			        success: res => {console.log(res);
			            if (res.data.code == 0) {
			                var data = res.data.data || null;
							var ads_data = data.data || null;
							var type_id = 0;
							var com_id = 0;
							var com_status = 0;
							// 先根据有无公司ID设置页面标题
							if(ads_data != null){
								type_id = parseInt(ads_data.type);
								com_id = parseInt(ads_data.id);
								com_status = parseInt(ads_data.status);
							}

							var upd_temp = {
								shopcategory:data.category || [],
								xieyi:data.xieyi || [],
							    editor_path_type: data.editor_path_type || '',
								tempid01:data.tempid01 || null,
								com_id:com_id || 0,
								com_status:com_status || 0,
							};
							// 如果已存后台，则以请求的为准，否则在页面初始化时候，会自动赋值hotel_info为缓存，但还得看这个本地缓存是否存在
							if(com_id > 0)
							{
								upd_temp['hotel_info'] = ads_data || null;
								uni.setStorageSync('classinfo_user_renzheng_info', ads_data);
							}else{
								// 若缓存不存在，则还是要给一个初始化的值的
								const value = uni.getStorageSync('classinfo_user_renzheng_info');
								if (value) {
									// 有缓存时候，将缓存赋值给ads_data，为下面的数据设置判断做基础
									// 如果缓存里有id,且有值，证明是保存过数据，此时以请求的数据为准，id为0是第一次提交，采用缓存
									if(value.id == 0)
									{
										ads_data = value;
									}
								}else{
									upd_temp['hotel_info'] = ads_data || null;
									uni.setStorageSync('classinfo_user_renzheng_info', ads_data);
								}
							}
							// 基础自定义分享
							var title = this.$t('pages.fcc-classinfo-companyreg');
							upd_temp['share_info'] = {
								title: title,
								desc: title,
								path: '/pages/fcc/classinfo/companyreg/companyreg'
							};
							this.setData(upd_temp);
			                
			                // 数据设置
			                if (ads_data != null) {
								// 编辑时，看还可以编辑几次，总的可编辑次数-已经编辑的次数
								var editnum = parseInt(data.edit_num) - parseInt(ads_data.edit_num);
								
			                    this.setData({
			                        province_id: ads_data.province || null,
			                        city_id: ads_data.city || null,
			                        county_id: ads_data.county || null,
									edit_num: editnum,
			                    });
			                    
			                    // 地理位置
			                    var lng = ads_data.lng || 0;
			                    var lat = ads_data.lat || 0;
			                    if (lng != 0 && lat != 0) {
			                        this.setData({
			                            user_location: {
			                                lng: lng,
			                                lat: lat,
			                                address: ads_data.address || ''
			                            }
			                        });
			                    }
			                }
			
			                // 地区数据填充处理
			                this.region_data_fill_handle();
			            } else {
							this.setData({
								data_list_loding_msg: res.data.msg
							});
							
			                if (app.globalData.is_login_check(res.data)) {
			                    app.globalData.showToast(res.data.msg);
			                }
			            }
			        },
			        fail: () => {
			            app.globalData.showToast(this.$t('user-address-save.user-address-save.2pey0m'));
			        }
			    });
			},
			
			// 地区数据填充处理
			region_data_fill_handle() {
			    // 获取城市、区县
			    this.get_city_list(true);
			    this.get_county_list(true);
			},
			
			// 地区数据初始化
			init_region_value() {
			    this.setData({
			        province_value: this.get_region_value("province_list", "province_id"),
			        city_value: this.get_region_value("city_list", "city_id"),
			        county_value: this.get_region_value("county_list", "county_id")
			    });
			},
			
			// 地区初始化匹配索引
			get_region_value(list, id) {
			    var data = this[list];
			    var data_id = this[id];
			    var value = null;
			    data.forEach((d, i) => {
			        if (d.id == data_id) {
			            value = i;
			            return false;
			        }
			    });
			    return value;
			},
			
			// 获取省份
			get_province_list() {
				var self = this;
				return new Promise(function(resolve, reject) {
					uni.request({
						url: app.globalData.get_request_url("index", "region"),
						method: "POST",
						data: {},
						dataType: "json",
						success: res => {console.log(res);
							if (res.data.code == 0) {
								var data = res.data.data;
								self.setData({
									province_list: data
								});
								
								resolve();
							} else {
								app.globalData.showToast(res.data.msg);
								reject(res.data.msg);
							}
						},
						fail: () => {
							app.globalData.showToast(this.$t('extraction-apply.extraction-apply.fo7y6c'));
							reject(this.$t('extraction-apply.extraction-apply.fo7y6c'));
						}
					});
				});
			},
			
			// 获取市
			get_city_list(is_init = false) {
			    if (this.province_id) {
			        uni.request({
			            url: app.globalData.get_request_url("index", "region"),
			            method: "POST",
			            data: {
			                pid: this.province_id
			            },
			            dataType: "json",
			            success: res => {
			                if (res.data.code == 0) {
			                    var data = res.data.data;
			                    this.setData({
			                        city_list: data
			                    });
			                    if(is_init) {
			                        this.init_region_value();
			                    }
			                } else {
			                    app.globalData.showToast(res.data.msg);
			                }
			            },
			            fail: () => {
			                app.globalData.showToast(this.$t('extraction-apply.extraction-apply.b6qg7b'));
			            }
			        });
			    }
			},
			
			// 获取区/县
			get_county_list(is_init = false) {
			    if (this.city_id) {
			        // 加载loding
			        uni.request({
			            url: app.globalData.get_request_url("index", "region"),
			            method: "POST",
			            data: {
			                pid: this.city_id
			            },
			            dataType: "json",
			            success: res => {
			                if (res.data.code == 0) {
			                    var data = res.data.data;
			                    this.setData({
			                        county_list: data
			                    });
			                    if(is_init) {
			                        this.init_region_value();
			                    }
			                } else {
			                    app.globalData.showToast(res.data.msg);
			                }
			            },
			            fail: () => {
			                app.globalData.showToast(this.$t('extraction-apply.extraction-apply.5s5734'));
			            }
			        });
			    }
			},
			
			// 省份事件
			select_province_event(e) {
			    var index = e.detail.value || 0;
			    if (index >= 0) {
			        var data = this.province_list[index];
			        this.setData({
			            province_value: index,
			            province_id: data.id,
			            city_value: null,
			            county_value: null,
			            city_id: null,
			            county_id: null
			        });
					
					var temp_hotel_info = this.hotel_info;
					temp_hotel_info['province'] = data.id;
					temp_hotel_info['province_id'] = data.id;
					uni.setStorageSync('classinfo_user_renzheng_info', temp_hotel_info);
					
			        this.get_city_list();
			    }
			},
			
			// 市事件
			select_city_event(e) {
			    var index = e.detail.value || 0;
			    if (index >= 0) {
			        var data = this.city_list[index];
			        this.setData({
			            city_value: index,
			            city_id: data.id,
			            county_value: null,
			            county_id: null
			        });
					var temp_hotel_info = this.hotel_info;
					temp_hotel_info['city'] = data.id;
					temp_hotel_info['city_id'] = data.id;
					uni.setStorageSync('classinfo_user_renzheng_info', temp_hotel_info);
					
			        this.get_county_list();
			    }
			},
			
			// 区/县事件
			select_county_event(e) {
			    var index = e.detail.value || 0;
			    if (index >= 0) {
			        var data = this.county_list[index];
			        this.setData({
			            county_value: index,
			            county_id: data.id
			        });
					var temp_hotel_info = this.hotel_info;
					temp_hotel_info['county'] = data.id;
					temp_hotel_info['county_id'] = data.id;
					uni.setStorageSync('classinfo_user_renzheng_info', temp_hotel_info);
			    }
			},
			
			// 省市区未按照顺序选择提示
			region_select_error_event(e) {
			    var value = e.currentTarget.dataset.value || null;
			    if (value != null) {
			        app.globalData.showToast(value);
			    }
			},
			
			// 选择地理位置
			choose_location_event(e) {
				// 可以跳转之前保存当前已存的信息，这样回调时不会丢失信息，延迟再跳转
				uni.setStorageSync('classinfo_user_renzheng_info', this.hotel_info);
				
				setTimeout(function() {
					uni.navigateTo({
					    url: '/pages/common/open-setting-location/open-setting-location'
					});
				}, 1000);
			},
			
			// 清除位置缓存信息
			user_location_remove() {
			    uni.removeStorage({
			        key: this.user_location_cache_key
			    });
			},
			
			// 地址信息初始化
			user_location_init() {
				var self = this;
			    var result = uni.getStorageSync(this.user_location_cache_key) || null;
			    var data = null;
				var str = '';
			    if (result != null) {
			        data = {
			            name: result.name || null,
			            address: result.address || null,
			            lat: result.lat || null,
			            lng: result.lng || null
			        };
					str = '定位信息：'+data.name+','+data.address+','+data.lat+','+data.lng+'，该定位信息不会改变你选择的具体地址，只在查看附近的商家时以该经纬度为准。';
					
					// 用完缓存数据后，清除
					this.user_location_remove();
			    }
				this.setData({
				    user_location: data,
				});
				 
				uni.getStorage({
					key: 'classinfo_user_renzheng_info',
					success: function (res) {
						console.log(res.data);
						var upd_temp = {
							agreement_status:((res.data || null) != null) ? (res.data.agreement_status || false) : this.agreement_status,
						};
						var temp_hotel_info = res.data;
						if (result != null) {
							temp_hotel_info['lat'] = data.lat || 0;
							temp_hotel_info['lng'] = data.lng || 0;
							temp_hotel_info['dingwei_address'] = str;
							upd_temp['hotel_info'] = temp_hotel_info;
							upd_temp['dingwei_address'] = str;
						}else{
							upd_temp['hotel_info'] = temp_hotel_info;
							upd_temp['dingwei_address'] = (res.data.dingwei_address || null) != null ? res.data.dingwei_address : '';
						}
						
						self.setData(upd_temp);
					}
				});
				uni.setStorageSync('classinfo_user_renzheng_info', this.hotel_info);
			    
				// 是否开启地理位置选择后自动识别
				if(result != null && this.is_user_address_location_discern == 1) {
				    this.address_discern_handle(result, 0, 1);
				}
			},
			
			// 文件上传
			file_upload_event(e) {
				if(app.globalData.is_android())
				{
					this.permissionID = 'CAMERA';
					setTimeout(()=>{
						this.$refs['authpup'].open(e);
					},500);
				}else{
					this.file_upload_event_true(e);
				}
			},
			// #ifdef APP-PLUS
			//用户授权权限后的回调
			changeAuth(e){
				if(this.permissionID == 'WRITE_EXTERNAL_STORAGE')
				{
					this.file_upload_event_true(e);
				}else{
					// 第一次是摄像头返回，再返回是相册权限，然后才继续执行
					this.permissionID = 'WRITE_EXTERNAL_STORAGE';
					setTimeout(()=>{
						this.$refs['authpup'].open(e);
					},500);
				}
			},
			// #endif
			file_upload_event_true(e) { 
			    var form_name = e.currentTarget.dataset.value || null;
			    if (form_name == null) {
			        app.globalData.showToast(this.$t('user-address-save.user-address-save.7w01kd'));
			        return false;
			    }
			
			    var self = this;
			    uni.chooseImage({
			        count: 1,
			        success(res) {
			            var success = 0;
			            var fail = 0;
			            var length = res.tempFilePaths.length;
			            var count = 0;
			            self.upload_one_by_one(res.tempFilePaths, success, fail, count, length, form_name);
			        }
			    });
			},
			
			// 采用递归的方式上传多张
			upload_one_by_one(img_paths, success, fail, count, length, form_name) {
			    var self = this;
			    uni.uploadFile({
			        url: app.globalData.get_request_url("index", "ueditor"),
			        filePath: img_paths[count],
			        name: 'upfile',
			        formData: {
			            action: 'uploadimage',
			            path_type: self.editor_path_type
			        },
			        success: function(res) {
			            success++;
			            if (res.statusCode == 200) {
			                var data = typeof res.data == 'object' ? res.data : JSON.parse(res.data);
			                if (data.code == 0 && (data.data.url || null) != null) {
								var temp_hotel_info = self.hotel_info;
								temp_hotel_info[form_name] = data.data.url;
			                    self.setData({
									hotel_info:temp_hotel_info
			                    });
								uni.setStorageSync('classinfo_user_renzheng_info', temp_hotel_info);
			                } else {
			                    app.globalData.showToast(data.msg);
			                }
			            }
			        },
			        fail: function(e) {
			            fail++;
			        },
			        complete: function(e) {
			            count++;
			            // 下一张
			            if (count >= length) { // 上传完毕，作一下提示
			                //app.showToast('上传成功' + success +'张', 'success');
			            } else {
			                // 递归调用，上传下一张
			                self.upload_one_by_one(img_paths, success, fail, count, length, form_name);
			            }
			        }
			    });
			},
			
			// 图片删除
			upload_delete_event(e) {
			    var form_name = e.currentTarget.dataset.value || null;
			    if (form_name == null) {
			        app.globalData.showToast(this.$t('user-address-save.user-address-save.7w01kd'));
			        return false;
			    }
			
			    var self = this;
			    uni.showModal({
					title: this.$t('common.warm_tips'),
					content: this.$t('recommend-list.recommend-list.54d418'),
					confirmText: this.$t('common.confirm'),
					cancelText: this.$t('recommend-list.recommend-list.w9460o'),
			        success(res) {
			            if (res.confirm) {
							var temp_hotel_info = self.hotel_info;
							var value = temp_hotel_info[form_name];
							temp_hotel_info[form_name] = '';
			                self.setData({
								hotel_info:temp_hotel_info
			                });
							uni.setStorageSync('classinfo_user_renzheng_info', temp_hotel_info);
							// 远程删除
							self.server_delete_img(form_name, value);
			            }
			        }
			    });
			},
			
			// 远程删除
			server_delete_img(form_name, value){
				uni.request({
				    url: app.globalData.get_request_url("deleteimg", "company", "classinfo"),
				    method: "POST",
				    data: {form_name:form_name, value:value},
				    dataType: "json",
				    success: res => {
						console.log(res);
					}
				});
			},
			
			// 远程自定义导航事件
			navigation_event(e) {
			    app.globalData.operation_event(e);
			},
			
			// 地址识别处理
			// data 地址信息
			// is_user 是否解析用户信息（0, 1）
			// type 0 用户输入地址信息识别, 1用户选择地理位置识别
			address_discern_handle(data, is_user = 0, type = 0) {
				
				return;
				
			    data['is_user'] = is_user;
			    uni.showLoading({
			        title: this.$t('common.processing_in_text'),
			        mask: true
			    });
			    uni.request({
			        url: app.globalData.get_request_url("address", "index", "intellectstools"),
			        method: "POST",
			        data: data,
			        dataType: "json",
			        success: res => {console.log(res);
			            uni.hideLoading();
			            if (res.data.code == 0) {
			                var temp_ads = this.hotel_info || {};
			                var ads_data = res.data.data;
			                var upd_data = {
			                    province_id: ads_data.province || null,
			                    city_id: ads_data.city || null,
			                    county_id: ads_data.county || null,
			                }
			                // 地址赋值
			                var arr = ['province', 'city', 'county', 'province_name', 'city_name', 'county_name', 'address'];
			                for(var i in arr) {
			                    if((ads_data[arr[i]] || null) != null) {
			                        temp_ads[arr[i]] = ads_data[arr[i]];
			                    }
			                }
			
			                // 用户手动识别操作
			                // 识别成功后清除用户选择的地理位置信息、避免坐标与识别的地址不相符
			                if(type == 0) {
			                    // 已获取的数据置为null
			                    upd_data['user_location'] = null;
			                    // 已有的地址坐标也清除
			                    temp_ads['lng'] = '';
			                    temp_ads['lat'] = '';
			                    // 清除位置缓存信息
			                    this.user_location_remove();
			                } else {
			                    // 地理位置则把名称加入别名
			                    temp_ads['alias'] = this.user_location.name;
			                }
			                upd_data['hotel_info'] = temp_ads;
							
							var temp_hotel_info = this.hotel_info;
							temp_hotel_info['province_id'] = ads_data.province || null;
							temp_hotel_info['city_id'] = ads_data.city || null;
							temp_hotel_info['county_id'] = ads_data.county || null;
							temp_hotel_info['address'] = ads_data.address || '';
							upd_data['hotel_info'] = temp_hotel_info;
							uni.setStorageSync('classinfo_user_renzheng_info', temp_hotel_info);
			                this.setData(upd_data);
			
			                // 地区数据填充处理
			                this.region_data_fill_handle();
			            } else {
			                if (app.globalData.is_login_check(res.data)) {
			                    app.globalData.showToast(res.data.msg);
			                } else {
			                    app.globalData.showToast(this.$t('common.sub_error_retry_tips'));
			                }
			            }
			        },
			        fail: () => {
			            uni.hideLoading();
			            app.globalData.showToast(this.$t('common.internet_error_tips'));
			        }
			    });
			},
			
			// 数据提交
			form_submit(e) {
				// 是否已同意协议
				if(!this.agreement_status) {
				    app.globalData.showToast(this.$t('login.login.btu2c1'));
				    return false;
				}
				var self = this;
			    // 表单数据
			    var form_data = this.hotel_info;//e.detail.value;
			    // 加入页面请求参数
			    form_data['params'] = this.params;
			
			    // 数据校验
				var str = (this.hotel_info.type == 0) ? this.$t('fengcheche.serv.laoban.companytittips') : this.$t('fengcheche.serv.laoban.personnametips');
				var str2 = (this.hotel_info.type == 0) ? this.$t('fengcheche.classinfo.reg.jieshaotips0') : this.$t('fengcheche.classinfo.reg.jieshaotips1');
				var str3 = (this.hotel_info.type == 0) ? this.$t('fengcheche.classinfo.reg.logotips0') : this.$t('fengcheche.classinfo.reg.logotips1');
				var validation = [
					{ fields: "name", msg: str },
					{ fields: "contact_tel", msg: this.$t('login.login.4c5n8o') },
					{ fields: "com_describe", msg: str2 },
					{ fields: "contact_wx", msg: this.$t('fengcheche.classinfo.reg.comwxtipx') },
					{ fields: "logo", msg: str3 },
				];
				
				// 是否校验营业执照
				if (this.hotel_info.type == 0) {
				    //validation.push({ fields: "com_images", msg: this.$t('fengcheche.serv.laoban.field07tips2') });
					//validation.push({ fields: "contact_name", msg: this.$t('fengcheche.serv.laoban.field08tips') });
					//validation.push({ fields: "jing_images", msg: this.$t('fengcheche.classinfo.reg.pictips') });
				}else{
					// 是否开启了用户身份证信息
					if (this.home_user_address_idcard_status == 1) {
					    //validation.push({ fields: "idcard_number", msg: this.$t('user-address-save.user-address-save.0x8i97') });
					    //validation.push({ fields: "idcard_front", msg: this.$t('user-address-save.user-address-save.224l36') });
					    //validation.push({ fields: "idcard_back", msg: this.$t('user-address-save.user-address-save.glf52g') });
					}
				}
				validation.push({ fields: "province", msg: this.$t('extraction-apply.extraction-apply.m99d2g') });
				validation.push({ fields: "city", msg: this.$t('extraction-apply.extraction-apply.03587o') });
				validation.push({ fields: "county", msg: this.$t('extraction-apply.extraction-apply.pt8436') });
				validation.push({ fields: "address", msg: this.$t('extraction-apply.extraction-apply.v1g617') });
			
			    // 是否开启了地理位置选择
			    /*if (this.home_user_address_map_status == 1) {
			        validation.push({ fields: "lng", msg: "请选择地理位置" });
			        validation.push({ fields: "lat", msg: "请选择地理位置" });
			    }*/
			console.log(form_data);
			    // 验证提交表单
			    if (app.globalData.fields_check(form_data, validation)) {
					// 清除可能存在的缓存
					uni.removeStorageSync('classinfo_user_renzheng_info');
					
			        // 数据保存
			        this.setData({
			            form_submit_disabled_status: true
			        });
			        uni.showLoading({
			            title: this.$t('common.processing_in_text')
			        });
			        uni.request({
			            url: app.globalData.get_request_url("companysave", "company", "classinfo"),
			            method: "POST",
			            data: form_data,
			            dataType: "json",
			            success: res => {console.log(res);
			                uni.hideLoading();
			                if (res.data.code == 0) {
			                    app.globalData.showToast(res.data.msg, "success");
			                    
								// 提示订阅消息，如果已经勾选不再提示，则不会再提示
								if((self.tempid01 || null) != null){
									uni.requestSubscribeMessage({
									  tmplIds: [self.tempid01],
									  success (res) {
									    console.log(res);
									  },
									  fail(res){
									    console.log(res);
									  },
									  complete(res){
									    setTimeout(function () {
									      uni.navigateBack();
									    }, 1000);
									  }
									});
								}else{
									setTimeout(function() {
									    self.init();
										self.setData({
										    form_submit_disabled_status: false
										});
									}, 1000);
								}
			                } else {
			                    this.setData({
			                        form_submit_disabled_status: false
			                    });
			                    if (app.globalData.is_login_check(res.data)) {
			                        app.globalData.showToast(res.data.msg);
			                    } else {
			                        app.globalData.showToast(this.$t('common.sub_error_retry_tips'));
			                    }
			                }
			            },
			            fail: () => {
			                this.setData({
			                    form_submit_disabled_status: false
			                });
			                uni.hideLoading();
			                app.globalData.showToast(this.$t('common.internet_error_tips'));
			            }
			        });
			    }
			}
		}
	}
</script>

<style>
@import './companyreg.css';
</style>
